﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using tmAsk.Common;

namespace tmAsk.Member
{
    public partial class editAsk : System.Web.UI.Page
    {
        tmAsk.Data.MakeHtml make = new tmAsk.Data.MakeHtml();
        tmAsk.Data.MakehtmlSQL SQL = new tmAsk.Data.MakehtmlSQL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                function.CheckUserLogin();
                string aid = Request.QueryString["id"];

                DataRow dr = SQL.GetList("b_ask", "a_id='" + aid + "'", "*").Tables[0].Rows[0];

                asktitle.Text = dr["a_title"].ToString();

                askContent.Value = dr["a_content"].ToString();
            }

        }
        protected void btnOk_Click(object sender, EventArgs e)
        {
            string aid = Request.QueryString["id"];
            if (aid == null || aid == "")
            {
                Response.Write(function.alert_text(2, "错误，没有选择数据或ID为空！", "myask.aspx"));
                return;
            }
            int i = SQL.ExecuteSql("update b_ask set a_title = '" + asktitle.Text + "',a_content='" + askContent.Value + "' where a_id=" + aid);
            if (i > 0)
            {
                Response.Write(function.alert_text(2, "修改成功", "myask.aspx"));
            }
            else
            {
                Response.Write(function.alert_text(2, "添加失败", "myask.aspx"));
            }
        }
    }
}